package orchestration.businessprocess.model.nodes;

import java.util.HashMap;
import java.util.Set;

import orchestration.businessprocess.model.BPArtifact;
import orchestration.businessprocess.model.BPNodeId;
import orchestration.businessprocess.model.IBPVisitor;

/**
 * An exclusive gateway has 1 predecessor and a set of successors.
 * Each successor has a condition attached.
 * If one of this conditions are true, the relative node should be visited
 *  
 * @author <a href="mailto:car.ferrarini@gmail.com">Carlo Ferrarini</a>
 *
 */
public class BPExGateway extends BPNode{

	private HashMap<BPNode,String> next2condition;
	BPExGateway(BPNodeId id,HashMap<BPNode,String> next,Set<BPArtifact> input) {
		super(id,BPNode.NODE_TYPE_EGW,input,null);
		this.next2condition=next;
	}
	public BPExGateway(BPNodeId id,Set<BPArtifact> input) {
		super(id,BPNode.NODE_TYPE_EGW,input,null);
		this.next2condition= new HashMap<BPNode, String>();
	}
	public Set<BPNode> getNexts(){
		return next2condition.keySet();
	}

	public String getConditionFor(BPNode next) {
		return next2condition.get(next);
	}
	
	@Override
	public void accept(IBPVisitor visitor) {
		visitor.visit(this);
	}
	public void addNext(BPNode next,String expression2check){
		this.next2condition.put(next, expression2check);
	}

}
